<?php
/**
 * Created by PhpStorm.
 * User: 悟能科技
 * Date: 2018/10/9
 * Time: 15:45
 */

namespace app\common\controller;


use app\common\model\Merchant;

class Payinfo
{

    //计算手续费
    public function service_charge($mid,$price,$types){
        switch ($types) {
            case "0":
                $type = "wx_service_charge";
                break;
            case "1":
                $type = "ali_service_charge";
                break;
            case "2":
                $type = "wx_service_charge";
                break;
            case "3":
                $type = "ali_service_charge";
                break;
            case "5":
                $type = "pos_service_charge";
                break;

        }
        $Merchant=new Merchant();
        $service_charge=$Merchant->where('id',$mid)->value($type);
        $fee=number_format(($service_charge/1000)*$price,2);
        return $fee;
    }
    public function service_charge_lft($mid,$price,$types){
        switch ($types) {
            case "0":
                $type = "wx_service_charge";
                break;
            case "1":
                $type = "ali_service_charge";
                break;
            case "2":
                $type = "wx_service_charge";
                break;
            case "3":
                $type = "ali_service_charge";
                break;
            case "5":
                $type = "pos_service_charge";
                break;
            case "20":
                $type = "wx_service_charge";
                break;

        }
        $Merchant=new Merchant();
        $service_charge=$Merchant->where('id',$mid)->value($type);
        $fee=service_changes(($service_charge/1000)*$price,2);
        return $fee;
    }

}